import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { BaseItem } from "../common/BaseItem";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ItemData } from "../../resource/info/ItemData";
import { Language } from "../../../../extend/language/Language";
import { ItemsUtil } from "../shortcuts/item/ItemsUtil";
import { Cache } from "../../cache/Cache";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
//class StrengthRenderer
    
    export  class StrengthRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.mouseChildren = false;
            this.doubleClickEnabled = true;
            return;
        }

        protected /* override */ configUI(): void
        {
            var loc1=ObjCreate.createBg(3, 0, 145, 56, this, ImagesConst.RechargeBottom);
            this._itemBg = ObjCreate.createBg(8, 10, 36, 36, this, ImagesConst.PackItemBg);
            this._item = new BaseItem();
            this._item.isDragAble = false;
            this._item.isDropAble = false;
            this._item.doubleClickEnabled = true;
            this._item.setSize(30, 30);
            this._item.move(11, 13);
            addChild(this._item);
            this._nameTxt = ObjCreate.createGTextField("", 53, 8, 95, 20, this);
            this._nameTxt.mouseEnabled = false;
            this._levelTxt = ObjCreate.createGTextField("", 53, 28, 95, 20, this, GlobalStyle.textFormatOrange);
            this._levelTxt.mouseEnabled = false;
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            if (arg1 && arg1 is ItemData) 
            {
                this._itemData = arg1 as ItemData;
                this._item.itemData = this._itemData;
                if (this._itemData.itemInfo) 
                {
                    this._nameTxt.htmlText = this._itemData.itemInfo.htmlName;
                }
                if (this._itemData.itemExInfo) 
                {
                    this._levelTxt.htmlText = Language.getString(36631) + "+" + this._itemData.itemExInfo.sp_eq_str;
                }
                else 
                {
                    this._levelTxt.htmlText = Language.getString(36631) + "+0";
                }
                this._isHd = ItemsUtil.isSpiritEquipHD(this._itemData);
                if (this._isHd) 
                {
                    this._isEnable = ItemsUtil.isSpiritEquipHDEnable(this._itemData);
                }
                else 
                {
                    this._isEnable = !Cache.instance.spiritEquip.isHadEat(this._itemData);
                }
                if (this._isEnable) 
                {
                    this.filters = null;
                    if (this._eatBitmap) 
                    {
                        this._eatBitmap.bitmapData = null;
                    }
                }
                else if (this._isHd) 
                {
                    this.filters = [FilterConst.colorFilter];
                }
                else 
                {
                    if (!this._eatBitmap) 
                    {
                        this._eatBitmap = ObjCreate.createBitmap(ImagesConst.EquipEatGray, 95, 30, this);
                    }
                    this._eatBitmap.bitmapData = GlobalClass.getBitmapData(ImagesConst.EquipEatGray);
                }
            }
            else 
            {
                this._item.itemData = null;
                this._nameTxt.htmlText = "";
                this._levelTxt.htmlText = "";
                this.filters = null;
                if (this._eatBitmap) 
                {
                    this._eatBitmap.bitmapData = null;
                }
            }
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            if (!this._isEnable) 
            {
                return;
            }
            super.selected = arg1;
            if (data && arg1) 
            {
                this.filters = [FilterConst.gradientGlowFilter];
            }
            else 
            {
                this.filters = null;
            }
            return;
        }

        protected /* var */_item: BaseItem;

        protected /* var */_itemData: ItemData;

        protected /* var */_itemBg: ScaleBitmap;

        protected /* var */_nameTxt: GTextFiled;

        protected /* var */_levelTxt: GTextFiled;

        protected /* var */_eatBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_isHd: Boolean;

        /* internal */ /* var */_isEated: Boolean;

        /* internal */ /* var */_isEnable: Boolean;
    }
